package com.dataextend.config;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

@Configuration
public class RedisConfig {
//    @Value("redis.host")
//    private String host;
//    @Value("redis.port")
//    private String port;
//    @Value("redis.password")
//    private String password;
//    @Value("redis.timeout")
//    private String timeout;


    @Bean(name = "jedisPoolConfig")
    public JedisPoolConfig setJedisPoolConfig() {
        JedisPoolConfig poolConfig = new JedisPoolConfig();
        poolConfig.setMaxTotal(30);
        poolConfig.setMaxIdle(25);
        poolConfig.setMinIdle(10);
        poolConfig.setMaxWaitMillis(1000);
        return poolConfig;
    }


    @Bean(name = "jedisPool")
    public JedisPool jedisPool(@Qualifier("jedisPoolConfig") JedisPoolConfig jedisPoolConfig) {
        return new JedisPool(jedisPoolConfig, "127.0.0.1", 6379, 1000, "123456");
    }

}
